<#include "../common/layout.ftl"/>
<@layout>
<div class="well" style="width: 44%;float: left">
	<span class="label label-success">填写会员信息</span>
	<form id="form1" class="well-left form-horizontal" action="saveOrgin"  method="post">
		<!-- <div class="control-group">
			<label class="control-label" for="focusedInput">vip类型：</label>
			<div class="controls">
				<select name="user_type" id="user_type" onclick="click()">
					<option value="0">个人</option>
					<option value="1">企业</option>
				</select>
			</div>
		</div>
		<div id="person">
	       <div class="control-group">
	        <label class="control-label" for="focusedInput">手机号码：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.cell_phone" id="cellphone" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">用户名：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.user_name" id="user_name" type="text"  style="height: 26"  >
	        </div>
	      </div>
	       <div class="control-group">
	        <label class="control-label" for="focusedInput">密码：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.password" id="password" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">真实姓名：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.real_name" id="realname" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">身份证：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.card_id" id="cardId" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">电子邮件：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.email_no" id="emailNo" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">车牌号码：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.plage_number" id="plage_number" type="text"  style="height: 26"  >
	        </div>
	      </div>
	       <div class="control-group">
	        <label class="control-label" for="focusedInput">性别：</label>
	        <div class="controls" >
	        	<select id="sex" name="member.sex">
	                <option value="0" selected>男</option>
	                <option value="1">女</option>
	                <option value="2">未知</option>
	              </select>
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">常用目的地：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.endpoint" id="endpoint" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">备注：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="member.remark" id="remark" type="text"  style="height: 26"  >
	        </div>
	      </div>
      </div>-->
      <div id="orgin">
      		<div class="control-group">
	        <label class="control-label" for="focusedInput">联系人：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="real_name" id="real_name" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">联系电话：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="cell_phone" id="cell_phone" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">单位名称：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="user_name" id="user_name" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">单位地址：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="adds" id="adds" type="text"  style="height: 26"  >
	        </div>
	      </div>
	      <div class="control-group">
	        <label class="control-label" for="focusedInput">备注：</label>
	        <div class="controls" >
	          <input class="input-xlarge focused" name="remark" id="remark" type="text"  style="height: 26"  >
	        </div>
	      </div> 
	      
      </div>
      
      <div class="control-group">
	        <label class="control-label" for="focusedInput">允许签单：</label>
	        <div class="controls" >
	          <input name="is_deal" id="is_deal" type="checkbox"/>
	        </div>
	      </div>
	      <input name="tels" id="tels" type="hidden"/>
      <div class="form-actions">
        <button type="button" class="btn btn-primary" id="save">确 定</button>
        <button type="reset" class="btn">重 置</button>
      </div>
      
      
  </form>
  </div>
  
  <div id="orgin_tel" class="well-tel" style="width: 49%;">
	      	<span class="label label-success">关联手机(至少写一条)</span>
	      	<br/>
	      	<input type="button" id="addTel" value="增加行"/>
			<input type="button" id="delTel" value="删除行"/>
		        <table id="telTab" name="telTab">
		        	<tr>
		        		<th></th>
		        		<th>手机号</th>
		        		<th>姓名</th>
		        		<th>常用目的地</th>
		        		<th>车牌号</th>
		        	</tr>
		        	<tr>
		        		<td>
		        			
		        		</td>
		        		<td>
		        			<input type="text"/>
		        		</td>
		        		<td>
		        			<input type="text"/>
		        		</td>
		        		<td>
		        			<input type="text"/>
		        		</td>
		        		<td>
		        			<input type="text"/>
		        		</td>
		        	</tr>
		        </table>
	      </div>

 <script>
	/*$(function() { 
     $("#form1").validity(function() {
         $("#user_name").require();
         $("#password").require();
         $("#realname").require();
         $("#cellphone").require().match("number");
         $("#plage_number").require();
         $("#cardId").require();
         $("#emailNo").require();
     });

     
 }); */
 $(document).ready(function(){ 
	$('#user_type').change(function(){
		alert($('#user_type').val());
		});
	$('#addTel').click(function(){
		debugger;
		var newRow="<tr><td><input name='select' type='checkbox' /></td><td><input type='text'/>"+
					"</td><td><input type='text'></td><td><input type='text'>"+
					"</td><td><input type='text'></td></tr>";
		$('#telTab tr:last').after(newRow);
		});
	$('#delTel').click(function(){
		debugger;
		var ckbs=$("#telTab input:checked");
		if(ckbs.size()==0){
	        alert("要删除指定行，需选中要删除的行！");
	        return;
	     }
         ckbs.each(function(){
            $(this).parent().parent().remove();
         });
	});

	$('#save').click(function(){
			 debugger;
			 if($('#realname').val()==""){
				alert("单位名称不可为空");
				return;
			}
			 var tels=[];
			//操作 table
			var $trAry = $("table#telTab tr");
			for (var i = 1; i < $trAry.length; i++) {
				var $tr = $($trAry[i]);
				var $tdAry =  $tr.find("td");
				var tel={};
				if($($tdAry[1]).find('input').val()==""){
					alert("手机号不可为空");
					return false;
				}
				//for(var j=0;i<$tdAry.length;j++){
					//tel.is_deal=$($($tdAry[0]).find('input')).attr("checked");
				tel.telephone=$($tdAry[1]).find('input').val();
				tel.name=$($tdAry[2]).find('input').val();
				tel.address=$($tdAry[3]).find('input').val();
				tel.car_id=$($tdAry[4]).find('input').val();
				//}
				tels[i-1]=tel;
			}
			$('#tels').val(JSON.stringify(tels));
			$('#form1').submit();
		});
	 }); 
 
</script>
</@layout>